Python for Secret Agents Second Edition by 2015

Python for Secret Agents Second Edition by 2015

Author:2015
Language: eng
Format: mobi, epub
Publisher: Packt Publishing


This shows us how many requests we can make in a given 15-minute interval. This is shows us how Twitter assures that its servers are responsive. When the limit remaining reaches zero, we're cut off.

The most interesting part of the response, however, is the JSON payload that was downloaded.

Here's a handy way to print that payload:

import json print( json.dumps(response.json(), indent=2) )

The value of response.json() is the Python object that had been encoded into JSON notation by the Twitter server. This is often a dictionary, but it can also be a list. We used the json module to create a nicely-formatted dump by rebuilding the JSON object from the Python object.

This does double the effort by creating a Python object from JSON and then recreating some JSON. It also introduces a tiny bit of variability because the Python object will use a default dictionary that does not guarantee the order of the keys. It's much easier to read, and it is worth the effort to make debugging easier.

The output is immense. It starts like this:

{ "contributors_enabled": false, "is_translation_enabled": false, "favourites_count": 494, "profile_link_color": "0084B4", "profile_sidebar_fill_color": "CC9933", "profile_background_color": "FFA200", "has_extended_profile": false, "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/498821312354058242/-H6BGz56.png", "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/498821312354058242/-H6BGz56.png", "statuses_count": 9651, "profile_image_url_https": "https://pbs.twimg.com/profile_images/622000526033592320/oHzUsSbm_normal.png", "profile_location": null, "utc_offset": 3600, "name": "Packt Publishing", "url": "http://t.co/vEPCgOu235",



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.